package com.lrkj.payfee.controller;

import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Api;
import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.lrkj.common.annotation.Log;
import com.lrkj.common.core.controller.BaseController;
import com.lrkj.common.core.domain.AjaxResult;
import com.lrkj.common.enums.BusinessType;
import com.lrkj.payfee.domain.PayOrder;
import com.lrkj.payfee.service.IPayOrderService;
import com.lrkj.common.utils.poi.ExcelUtil;
import com.lrkj.common.core.page.TableDataInfo;

/**
 * 费用支付订单Controller
 *
 * @author yajun_ren
 * @date 2022-08-19
 */
@RestController
@RequestMapping("/payfee/payOrder")
@Api(tags = "费用支付订单")
public class PayOrderController extends BaseController
{
    @Autowired
    private IPayOrderService payOrderService;

    /**
     * 查询费用支付订单列表
     */
    @ApiOperation(value = "查询费用支付订单列表", notes = "查询费用支付订单列表")
    @PreAuthorize("@ss.hasPermi('payfee:payOrder:list')")
    @GetMapping("/list")
    public TableDataInfo list(PayOrder payOrder)
    {
        startPage();
        this.changeParameter(payOrder.getParams());
        List<PayOrder> list = payOrderService.selectPayOrderList(payOrder);
        return getDataTable(list);
    }

    /**
     * 导出费用支付订单列表
     */
	@ApiOperation(value = "导出费用支付订单列表", notes = "导出费用支付订单列表")
    @PreAuthorize("@ss.hasPermi('payfee:payOrder:export')")
    @Log(title = "费用支付订单", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(PayOrder payOrder)
    {
        List<PayOrder> list = payOrderService.selectPayOrderList(payOrder);
        ExcelUtil<PayOrder> util = new ExcelUtil<PayOrder>(PayOrder.class);
        return util.exportExcel(list, "费用支付订单数据");
    }

    /**
     * 获取费用支付订单详细信息
     */
	@ApiOperation(value = "获取费用支付订单详细信息", notes = "获取费用支付订单详细信息")
    @PreAuthorize("@ss.hasPermi('payfee:payOrder:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(payOrderService.selectPayOrderById(id));
    }

    /**
     * 新增费用支付订单
     */
    @ApiOperation(value = "新增费用支付订单", notes = "新增费用支付订单")
    @PreAuthorize("@ss.hasPermi('payfee:payOrder:add')")
    @Log(title = "费用支付订单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PayOrder payOrder)
    {
        return toAjax(payOrderService.insertPayOrder(payOrder));
    }

    /**
     * 修改费用支付订单
     */
    @ApiOperation(value = "修改费用支付订单", notes = "修改费用支付订单")
    @PreAuthorize("@ss.hasPermi('payfee:payOrder:edit')")
    @Log(title = "费用支付订单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PayOrder payOrder)
    {
        return toAjax(payOrderService.updatePayOrder(payOrder));
    }

    /**
     * 删除费用支付订单
     */
    @ApiOperation(value = "删除费用支付订单", notes = "删除费用支付订单")
    @PreAuthorize("@ss.hasPermi('payfee:payOrder:remove')")
    @Log(title = "费用支付订单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(payOrderService.deletePayOrderByIds(ids));
    }
}
